//
//  STAboutUsViewController.m
//  STBasicsApp
//
//  Created by jerry on 2019/5/6.
//  Copyright © 2019 jerry. All rights reserved.
//

#import "STAboutUsViewController.h"
#import "STAboutUsBottomView.h"
#import "STFramework/UIView+STNib.h"

@interface STAboutUsViewController ()

@property (nonatomic , strong) UIImageView * iconIv;
@property (nonatomic , strong) UILabel * titleLabel;
@property (nonatomic , strong) UILabel * contentLabel;
@property (nonatomic , strong) STAboutUsBottomView * bottom;

@end

@implementation STAboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configNav];
    [self showView];
}

- (void)configNav{
    self.title = ASLocalizedString(@"关于我们");
}

- (void)showView{
    
    [self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).offset(30);
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.mas_equalTo(self.iconIv.mas_bottom).offset(15);
         make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(15);
        make.left.mas_equalTo(self.view.mas_left).offset(12);
        make.right.mas_equalTo(self.view.mas_right).offset(-12);
    }];
    
    [self.bottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(20);
        make.left.mas_equalTo(self.contentLabel.mas_left);
        make.right.mas_equalTo(self.contentLabel.mas_right);
        make.height.mas_equalTo(180);
    }];
    
    
    
}

#pragma mark - set/get

- (UIImageView *)iconIv{
    if (!_iconIv) {
        _iconIv = [[UIImageView alloc]init];
        _iconIv.backgroundColor = kRedColor;
        [self.view addSubview:_iconIv];
    }
    return _iconIv;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = ASLocalizedString(@"公司简介");
        _titleLabel.font = kFont(18.0f);
        _titleLabel.dk_textColorPicker = DKColorPickerWithKey(MAINTEXT);
        [self.view addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UILabel *)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc]init];
        _contentLabel.text = ASLocalizedString(@"XXXX是福建厦门网络有限公司旗下素材在线交易网站，于2016年7月上线运营。主要服务是提供图片、视频、音频、psd源文件等形式的素材。XXXX内容板块已有广告设计、摄影图、字体、UI设计、电商淘宝、多媒体、办公文档、装饰模型、插画配图九大类别。");
        _contentLabel.font = kFont(16.0f);
        _contentLabel.numberOfLines = 10;
        _contentLabel.dk_textColorPicker = DKColorPickerWithKey(MAINTEXT);
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:_contentLabel.text];
        NSMutableParagraphStyle   *paragraphStyle   = [[NSMutableParagraphStyle alloc] init];
        
        //行间距
        [paragraphStyle setLineSpacing:6.0];
        //第一行头缩进
        [paragraphStyle setFirstLineHeadIndent:25.0];
        
        //段落间距
        //[paragraphStyle setParagraphSpacing:10.0];
        //头部缩进
        //[paragraphStyle setHeadIndent:15.0];
        //尾部缩进
        //[paragraphStyle setTailIndent:250.0];
        //最小行高
        //[paragraphStyle setMinimumLineHeight:20.0];
        //最大行高
        //[paragraphStyle setMaximumLineHeight:20.0];
        
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [_contentLabel.text length])];
        [_contentLabel setAttributedText:attributedString];
        
        [self.view addSubview:_contentLabel];
    }
    return _contentLabel;
}

- (STAboutUsBottomView *)bottom{
    if (!_bottom) {
        _bottom = [STAboutUsBottomView loadInstanceFromSTNibWithName:@"STAboutUsBottomView"];
        //_bottom.frame = CGRectMake(0, 0, OG_SCREEN_WIDTH, 180);
        [self.view addSubview:_bottom];
    }
    return _bottom;
}

@end
